package com.jlect.swebing.ui.laf.basic.client;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

/**
 * Generate attach events
 *
 * @author Sergey Kozmin
 * @since 16.11.2007 10:50:05
 */
public class CompositeAttachEventProvider extends Composite implements AttachEventSource {
    private AttachListener listener;
    private Widget targetWidget;

    public CompositeAttachEventProvider(Widget targetWidget) {
        this.targetWidget = targetWidget;
        initWidget(targetWidget);
    }

    protected void onLoad() {
        super.onLoad();
        if(listener != null) {
            listener.onLoad();
        }
    }

    protected void onUnload() {
        super.onUnload();
        if(listener != null) {
            listener.onUnload();
        }
    }

    public void setAttachListener(AttachListener listener) {
        this.listener = listener;
    }

    public Widget getTargetWidget() {
        return targetWidget;
    }
}
